#!/usr/bin/env python
from os import getcwd,listdir
from ase.io import read
from ase.io.trajectory import TrajectoryWriter
from ase.calculators.singlepoint import SinglePointCalculator
from irff.irff_np import IRFF_NP


cdir  = getcwd()
files = listdir(cdir)
traj  = TrajectoryWriter('3RD.traj',mode='w')
trds  = [] 

for fil in files:
    f = fil.split('.')
    if len(f)==3:
       if f[0]=='3RD' and f[1]=='POSCAR':
          trds.append(f[2])

trds.sort()
# print(trds)
atoms = read('3RD.POSCAR.001')
ir    = IRFF_NP(atoms=atoms,libfile='ffield.json',nn=True)

for i in trds:
    atoms = read('3RD.POSCAR.{:s}'.format(i))
    ir.calculate(atoms)
    atoms.calc = SinglePointCalculator(atoms,energy=ir.E)
    traj.write(atoms=atoms)
traj.close()
   

